﻿using System;
using System.Collections.Generic;
using System.Web;
using HZ.BidSystem.Model;

/// <summary>
/// 当前项目上下文信息
/// </summary>
public class CurrentProject
{
    /// <summary>
    /// 获取项目配置
    /// </summary>
    public static ProjectConfig ProjectConfig
    {
        get
        {
            return BLL_Factory.IBLL_Common.GetProjectConfigById(CurrentAccount.ProjectId);
        }
    }

    #region 报价开关时间相关


    /// <summary>
    /// 是否开启报价
    /// </summary>
    public static bool IsBidSwitch
    {
        get
        {
            return ProjectConfig.BidSwitch ?? false;
        }
    }

    /// <summary>
    /// 是否在报价期内
    /// 小于0 早于报价时间
    /// ＞0 晚于报价时间
    /// 等于0 报价时间内
    /// </summary>
    public static Int32 InBidTime
    {
        get
        {
            if (ProjectConfig.BidStartTime != null && DateTime.Now < ProjectConfig.BidStartTime.Value)
            {
                return -1;
            }
            if (ProjectConfig.BidStartTime != null && DateTime.Now > ProjectConfig.BidEndTime.Value)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }

    #endregion

    #region 议价开关时间相关


    /// <summary>
    /// 是否打开议价开关
    /// </summary>
    public static bool IsBargainSwitch
    {
        get
        {
            return ProjectConfig.BargainSwitch ?? false;
        }
    }

    /// <summary>
    /// 是否在议价期内
    /// 小于0 早于报价时间
    /// ＞0 晚于报价时间
    /// 等于0 报价时间内
    /// </summary>
    public static Int32 InBargainTime
    {
        get
        {
            if (ProjectConfig.BargainStartTime != null && DateTime.Now < ProjectConfig.BargainStartTime.Value)
            {
                return -1;
            }
            if (ProjectConfig.BargainEndTime != null && DateTime.Now > ProjectConfig.BargainEndTime.Value)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }


    /// <summary>
    /// 第二轮是否在议价期内
    /// 小于0 早于报价时间
    /// ＞0 晚于报价时间
    /// 等于0 报价时间内
    /// </summary>
    public static Int32 InBargainTime2
    {
        get
        {
            if (ProjectConfig.SecondBargainStartTime != null && DateTime.Now < ProjectConfig.SecondBargainStartTime.Value)
            {
                return -1;
            }
            if (ProjectConfig.SecondBargainEndTime != null && DateTime.Now > ProjectConfig.SecondBargainEndTime.Value)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }


    #endregion

    #region 解密开关时间相关
    /// <summary>
    /// 是否开启解密开关
    /// </summary>
    public static bool IsDecSwitch
    {
        get
        {
            return ProjectConfig.DecSwitch ?? false;
        }
    }

    /// <summary>
    /// 是否在解密期间
    /// 小于0 早于报价时间
    /// ＞0 晚于报价时间
    /// 等于0 报价时间内
    /// </summary>
    public static Int32 InDecTime
    {
        get
        {
            if (ProjectConfig.DecStartTime != null && DateTime.Now < ProjectConfig.DecStartTime.Value)
            {
                return -1;
            }
            if (ProjectConfig.DecEndTime != null && DateTime.Now > ProjectConfig.DecEndTime.Value)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }
    /// <summary>
    /// 是否开机竞价开关
    /// </summary>
    public static bool IsCompeteSwitch
    {
        get
        {
            return ProjectConfig.CompeteSwitch ?? false;
        }
    }


   
    #endregion
}
